<?php class wgm_user {
	
	var $id;
	var $nom;
	var $groupes;
	var $avatar;
	
	function wgm_user($var) {
		if (is_object ( $var )) {
			$this->id = $var->id;
			$this->nom = $var->nom;
			$this->groupes = 0;
			$this->avatar = $var->avatar;
		} elseif (is_array ( $var )) {
			$this->id = $var ["id"];
			$this->nom = $var ["nom"];
			$this->groupes = 0;
			$this->avatar = $var ["avatar"];
		}
	}
	
	function user_is_in_group($groupe) {
		$tmp = explode ( ",", $this->groupes );
		if (in_array ( $groupe, $tmp ))
			return true;
		else
			return false;
	}
	
	function user_is_in_groups($groupes) {
		$groups = explode ( ",", $groupes );
		foreach ( $groups as $group ) {
			if ($this->user_is_in_group ( $group ))
				return true;
		}
		return false;
	}
	
	function init_groups() {
		global $sql;
		if(!is_object($sql)) $sql= new sql();
		
		$res = $sql->request ( "select * from " . CFG_MYSQL_PREFIX . "user_groupe where idUser=" . $this->id );
		foreach ( $res as $var )
			$this->groupes .= "," . $var->idGroupe;
	}
} ?>